from django.urls import path
from apps.meiduo_admin.views import statistical,users,goods,images,skus,orders,perms,groups,admins
from rest_framework_jwt.views import obtain_jwt_token

urlpatterns = [
    path('authorizations/', obtain_jwt_token),
    # --------------数据统计--------------
    # --------------用户总数统计-------------
    path('statistical/total_count/',statistical.UserTotalCountView.as_view() ),
    # --------------日增用户统计-------------
    path('statistical/day_increment/',statistical.UserDayIncrementView.as_view() ),
    # --------------日活用户统计-------------
    path('statistical/day_active/',statistical.UserDayActiveView.as_view() ),
    # --------------日下单用户统计-------------
    path('statistical/day_orders/',statistical.UserDayOrdersView.as_view() ),
    # --------------月新增用户统计-------------
    path('statistical/month_increment/',statistical.UserMonthIncrementView.as_view() ),
    # --------------商品访问量统计-------------
    path('statistical/goods_day_views/',statistical.UserGoodsDayView.as_view() ),


    # ------------------用户管理--------------------
    # ------------------获取查询用户和增加用户--------------------
    path('users/',users.UsersView.as_view() ),



    # ------------------商品管理-------------
    # ------------------规格表管理-------------
    # path('goods/specs/',goods.GoodsSpecViews.as_view({'get': 'list'}) ),
    path('goods/simple/', goods.GoodsSpecViews.as_view({'get': 'simple'})),
    path(r'skus/simple/', images.SKUImageViews.as_view({'get': 'simple'})),
    # 获取商品的规格信息
    path(r'goods/<int:pk>/specs/', skus.SKUSViews.as_view({'get': 'specs'})),

    #---------------------订单管理------------------------
    path(r'orders/', orders.OrderView.as_view()),
    path(r'orders/<int:pk>/', orders.OrderDetailView.as_view()),
    path(r'orders/<int:pk>/status/', orders.OrderDetailView.as_view()),

    # 获取权限类型 PermsView视图集
    path(r'permission/content_types/', perms.PermsView.as_view({'get':'content_types'})),
    # 获取简单权限
    path(r'permission/simple/', groups.GroupsView.as_view({'get': 'simple'})),
    path(r'permission/groups/simple/',admins.AdminsView.as_view({'get':'simple'})),
]

# 视图集可以采用自动生成路由类
from rest_framework.routers import DefaultRouter

router = DefaultRouter()
router.register('goods/specs', goods.GoodsSpecViews, basename='googdspecs')
# 图片表
router.register('skus/images', images.SKUImageViews, basename='skuinage')
router.register('skus', skus.SKUSViews, basename='skus')
# 权限表
router.register('permission/perms', perms.PermsView, basename='perms')
# 分组表
router.register('permission/groups', groups.GroupsView, basename='groups')
# 管理员
router.register('permission/admins', admins.AdminsView, basename='admins')
urlpatterns += router.urls